package cn.zcscloud.mall.service.impl;

import cn.zcscloud.mall.mbg.mapper.PmsProductAttributeMapper;
import cn.zcscloud.mall.mbg.model.PmsProductAttribute;
import cn.zcscloud.mall.service.PmsProductAttributeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class PmsProductAttributeServiceImpl extends ServiceImpl<PmsProductAttributeMapper, PmsProductAttribute> implements PmsProductAttributeService {



    @Override
    public Map getByCids(List<Long> productAttributeCategoryIds) {

        LambdaQueryWrapper<PmsProductAttribute> queryWrapper = new LambdaQueryWrapper<>();

        queryWrapper.in(PmsProductAttribute::getProductAttributeCategoryId,productAttributeCategoryIds);

        List<PmsProductAttribute> list = this.list(queryWrapper);

        Map<Long, List<PmsProductAttribute>> map = list.stream().collect(Collectors.groupingBy(PmsProductAttribute::getProductAttributeCategoryId));

        return map;
    }
}
